import { ref, computed, reactive } from "vue";
import { defineStore } from "pinia";
import { useRouter } from "vue-router";
import type { User } from "@/types/User";
export const useTokenStore = defineStore(
  "token",
  () => {
    const router = useRouter();
    const userInfo = ref<User>({});

    


    const toLogin = () => {
      clear()
      router.replace("/login");
    };

    const clear = () => {
      userInfo.value = {}
    }

    return {
      userInfo,
    
      toLogin,
      clear
    };
  },
  { persist: true }
);
